/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beanUser;

import com.matrimonysite.entity.UserPersonal;

import com.matrimonysite.sessionbean.UserPersonalFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author khanhnguyen
 */
@ManagedBean (name = "AddPersonal")
@SessionScoped
public class AddPersonal {
    @EJB
    private UserPersonalFacade userPersonalFacade;
    private UserPersonal userPersonal;
    List<UserPersonal> userPersonalList;

    public UserPersonal getUserPersonal() {
        return userPersonal;
    }

    public void setUserPersonal(UserPersonal userPersonal) {
        this.userPersonal = userPersonal;
    }
    
    /**
     * Creates a new instance of AddPersonal
     */
    public AddPersonal() {
        userPersonal = new UserPersonal();
        userPersonalFacade = new UserPersonalFacade();
    }
    
    public void createUserPersonal(){
        Integer init= userPersonal.getPersonalID();
        userPersonal.getPersonalID();
        userPersonal.getSelfFeatures();
        userPersonal.getFamilyDetails();
        userPersonal.getWorkAt();
        userPersonal.getQualificationStatus();
        userPersonal.getDesignation();
        userPersonal.getCityID();
        userPersonal.getFavoriteHobbies();
        userPersonal.getFavoriteMusics();
        userPersonal.getFavoriteMovies();
        userPersonal.getFavoriteBooks();
        userPersonal.getFavoriteCuisines();
        userPersonal.getFavoritePlace();
        
        userPersonalFacade.create(userPersonal);
        
    }
    public void editUserPersonal(){
        userPersonalFacade.edit(userPersonal);
        FacesContext face = FacesContext.getCurrentInstance();
        face.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update personal Success.", "Update personal Success."));
    }
    public void deleteUserPersonal(){
        Integer init = userPersonal.getPersonalID();
        userPersonal.setPersonalID(init);
        userPersonalFacade.remove(userPersonal);
    }
    
    public List<UserPersonal> getAllUserPersonal(){
        return userPersonalFacade.getAllUserPersonal();
    }
}
